package com.atguigu.jinx.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author steve
 * @date 2025/08/27 18:10
 */


@Getter
@AllArgsConstructor
public enum RecordStatus {
    RECHARGE("recharge", "充值"),
    INCOME("income", "收入"),
    WITHDRAW("withdraw", "提现");

    private final String code;
    private final String name;

    /**
     * 根据 code 获取枚举
     */
    public static RecordStatus fromCode(String code) {
        for (RecordStatus status : RecordStatus.values()) {
            if (status.getCode().equalsIgnoreCase(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown code: " + code);
    }
}

